'''
Additions to basic Python types (or re-implementations of stuff that's added
in later versions of Python).
'''

def product(*args, **kwds):
    """
    Re-implementation (mostly) of itertools.product, for pre-Python 2.6.
    """
    # product('ABCD', 'xy') --> Ax Ay Bx By Cx Cy Dx Dy
    # product(range(2), repeat=3) --> 000 001 010 011 100 101 110 111
    pools = map(tuple, args) * kwds.get('repeat', 1)
    result = [[]]
    for pool in pools:
        result = [x+[y] for x in result for y in pool]
    for prod in result:
        yield tuple(prod)
